﻿Imports DTO
Public Class HoaDon_DAL
    Dim connect As Connection
    Dim stringCommand As String
    Dim hoaDon As HoaDon
    Dim ds_hoaDon As List(Of HoaDon)

    Public Function LoadData() As List(Of HoaDon)
        connect = New Connection()
        stringCommand = "Select * From HoaDon"
        ds_hoaDon = New List(Of HoaDon)
        Dim dt As New DataTable()
        dt = connect.LoadData(stringCommand)
        For i As Integer = 0 To dt.Rows.Count - 1
            Dim id As Integer = dt.Rows(i)(0)
            Dim tiecCuoi As Integer = dt.Rows(i)(1)
            Dim ngayThanhToan As DateTime = dt.Rows(i)(2)
            Dim soLuongBan As Integer = dt.Rows(i)(3)
            Dim tongTienDichVu As Double = dt.Rows(i)(4)
            Dim donGiaBan As Double = dt.Rows(i)(5)
            Dim tongTienHoaDon As Double = dt.Rows(i)(6)
            hoaDon = New HoaDon(id, tiecCuoi, ngayThanhToan, soLuongBan, tongTienDichVu, donGiaBan, tongTienHoaDon)
            ds_hoaDon.Add(hoaDon)
        Next
        Return ds_hoaDon
    End Function
    Public Function Insert(ByVal hoaDon As HoaDon)
        connect = New Connection()
        stringCommand = "Insert HoaDon(ID,TiecCuoi,NgayThanhToan,SoLuongBan,TongTienDichVu,DonGiaBan,TongTienHoaDon) Values('" & hoaDon.Id & "','" & hoaDon.Ngày_Thanh_Toán & "','" & hoaDon.Số_Lượng_Bàn & "','" & hoaDon.Tổng_Tiền_Dịch_Vụ & "','" & hoaDon.Đơn_Giá_Bàn & "','" & hoaDon.Tổng_Tiền_Hóa_Đơn & ")"
        Return connect.ExecuteData(stringCommand)
    End Function
End Class
